package com.snap.vseries.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.snap.vseries.R;
import com.snap.vseries.base.BaseRecycleAdapter;
import com.snap.vseries.base.BaseViewHolder;
import com.snap.vseries.ui.HisSearchResultActivity;

import java.util.List;

public class SearchHistoryAdapter extends BaseRecycleAdapter<String> {
    public SearchHistoryAdapter(Context context, List<String> dataList) {
        super(context, dataList);
    }

    @Override
    public void bindData(BaseViewHolder holder, String data, int position) {
        holder.setText(R.id.tv_name, data);
        holder.getView(R.id.tv_name).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, HisSearchResultActivity.class);
                intent.putExtra("search_content", data);
                mContext.startActivity(intent);
                ((Activity) mContext).finish();
                // TODO: 2019/10/9 是否做搜索记录的唯一性检查，是否重新排序
            }
        });
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.layout_search_his_item;
    }

    @Override
    public void updateData(List<String> dataList) {
        super.updateData(dataList);
    }
}
